package com.master.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.master.entity.User;



public class LoginDao {
	public User login(String LOGIN_ID,String LOGIN_PSW){
		User u = new User();
		ResultSet rs = null;
		Connection conn = null;
		PreparedStatement pstmt = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/adminsys", "root", "123456");
			String sql = "select * from sys_admin where LOGIN_ID=? and LOGIN_PSW =?";
			pstmt =conn.prepareStatement(sql);
			pstmt.setString(1, LOGIN_ID);
			pstmt.setString(2, LOGIN_PSW);
			rs = pstmt.executeQuery();
			while(rs.next()){
				u.setAID(rs.getInt("AID"));
				u.setLOGIN_ID(rs.getString("LOGIN_ID"));
				u.setLOGIN_PSW(rs.getString("LOGIN_PSW"));
			}
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			
		}
		
		return u;
	}
}
